#include <math.h>
Public Member Functions |
|
Vector (void) throw () | |
Constructs the vector with zero values.
|
|
Vector (float fX, float fY, float fZ=0.0f) throw () | |
Constructs the vector with specified values.
|
|
Vector (const Vector &vVector) throw () | |
Copy constructor. |
|
Vector (const char *pVector) throw () | |
Construct the vector from a pointer to 8bit
signed data. |
|
Vector (const short *pVector) throw () | |
Construct the vector from a pointer to 16bit
signed data. |
|
Vector & | Set (float fX, float fY, float fZ) throw () |
Sets the values of the vector elements and
returns the vector. |
|
Vector & | Clear (void) throw () |
Zeros all the components of the Vector, then returns
it. |
|
Vector & | Normalize (void) throw () |
Normalizes the vector and returns it.
|
|
Vector & | NormalizeApprox (void) throw () |
Normalizes the vector and returns it.
|
|
Vector | Normalized (void) const throw () |
Returns a normalized version of the vector,
without changing this vector. |
|
Vector & | MakeOrthogonal (const Vector &vBase) |
Makes this vector orthogonal to the given
vBase vector and normalizes it. Returns the vector. |
|
Vector & | SetLength (float fLength) |
Sets the vector to the given length, without
changing its direction. |
|
Vector & | RotateOrthogonal (const Vector &vBase) |
Rotates this vector to be orthogonal to
vBase without changing its length, and returns it. |
|
float | LengthSquare (void) |
Returns the square of the length of the
vector. |
|
float | Length () const throw () |
Returns the length of the vector. |
|
float | Length2D () const throw () |
Returns the 2D length of the vector,
ignoring the z element. |
|
float | DistanceFrom (const Vector &v) const |
Returns the distance between two points
(this and another, represented as Vector objects). |
|
float | DistanceFromLine (const Vector &v0, const Vector &v1) const |
Returns the shortest distance between this
point and a line defined by two other points (all points
represented by vector objects). |
|
const Vector & | Relocate2D (const Vector &v0, const Vector &v1) |
Converts this (2d) vector to represent
itself as a linear combination of the supplied basis vectors.
Returns the result. |
|
void | Relocate (const Vector &v0, const Vector &v1, const Vector &v2) |
Converts this vector to represent itself as
a linear combination of the supplied basis vectors. |
|
bool | Relocate2DQuad (const Vector &v0, const Vector &v1, const Vector &v2, const Vector &v3) |
This operation calculates the baricentric
coordinates inside a quad where the quad corners are v0,v1,v2,v3.
|
|
float | AngleCos (const Vector &v1) const throw () |
Returns the cosine of the angle between this
vector and the one passed in. |
|
Vector | Minimum (const Vector &o) |
Returns the minimum of this and the argument
vector. |
|
Vector | Maximum (const Vector &o) |
Returns the maximum of this and the argument
vector. |
|
Vector | operator- (void) const throw () |
Returns the inverse of the vector. |
|
Vector | operator+ (float f) const throw () |
Returns the sum of a vector and a scalar.
|
|
Vector | operator+ (const Vector &v) const throw () |
Returns the sum of two vectors. |
|
Vector | operator- (const Vector &v) const throw () |
Returns the difference between two
vectors/points. |
|
Vector | operator * (const Vector &v) const throw () |
Returns the product of two vectors by
components. |
|
Vector | operator * (float f) const throw () |
Returns the product of the vector and a
scalar. |
|
Vector | operator/ (const Vector &v) const throw () |
Returns the quotient of two vectors by
components. |
|
Vector | operator/ (float f) const throw () |
Returns the quotient of a vector and a
scalar. |
|
Vector | operator * (int i) const throw () |
Returns the product of a vector and an
integer. |
|
Vector | operator/ (int i) const throw () |
Returns the quotient of a vector and an
integer. |
|
Vector | operator/ (unsigned int i) const throw () |
Returns the quotient of a vector and an
unsigned integer. |
|
float | operator| (const Vector &v) const throw () |
Returns the dot product of two vectors.
|
|
Vector | operator & (const Vector &v) const |
Returns the cross product of two vectors.
|
|
bool | operator== (const Vector &v) const throw () |
Returns true if the two vectors are
identical, false otherwise. |
|
bool | operator!= (const Vector &v) const throw () |
Returns true if the two vectors are
different, false otherwise. |
|
operator bool (void) const throw () | |
Returns true if the vector is not a
zero vector, false otherwise. |
|
bool | operator! (void) const throw () |
Returns true if the vector is a zero
vector, false otherwise. |
|
Vector & | operator= (const Vector &v) |
Sets this vector to equal another one and
returns it. |
|
Vector & | operator<< (const Vector &v) |
Sets this vector to equal another one and
returns it. |
|
Vector & | operator-= (const Vector &v) throw () |
Subtracts the component values of another
vector from this one's, and returns the result. |
|
Vector & | operator+= (const Vector &v) throw () |
Adds another vector to this one and returns
the result. |
|
Vector & | operator *= (float f) |
Multiplies the components of the vector with
a scalar value and returns the result. |
|
Vector & | operator *= (const Vector &v) |
Multiplies the vector with another vector by
components and returns the result. |
|
Vector & | operator/= (float f) |
Divides the vector by a scalar and returns
the result. |
|
float & | operator[] (int i) throw () |
Returns a individual components of the
vector. |
|
float & | operator[] (unsigned int i) throw () |
Returns a component of the vector. |
|
operator const float * (void) const | |
Returns a pointer to the data of the vector.
Do not delete this pointer. |
|
Constructs the vector with zero values. |
|
Constructs the vector with specified values. |
|
Copy constructor. |
|
Construct the vector from a pointer to 8bit signed data. The array must have at least 3 elements, with values in the range -127 to +127. |
|
Construct the vector from a pointer to 16bit signed data. The array must have at least 3 elements in the range -32767 to +32767. |
|
Sets the values of the vector elements and returns the vector. |
|
Zeros all the components of the Vector, then returns it. 00057 { return Set( 0.0f, 0.0f, 0.0f ); }; |
|
Normalizes the vector and returns it. If the vector is zero length, it is set to (0,1,0) |
|
Normalizes the vector and returns it. If the vector is zero length, it is set to (0,1,0) TO BE REMOVED. This was an experiment at improving speed in exchange for accurracy. |
|
Returns a normalized version of the vector, without changing this vector. |
|
Makes this vector orthogonal to the given vBase vector and normalizes it. Returns the vector. The resulting vector will lie on the plane defined by the original value of this vector, and vBase. |
|
Sets the vector to the given length, without changing its direction. If the vector is of zero length, then it is arbitrarily made parallel to the Y axis. 00086 { Normalize(); operator *=( fLength ); return *this; }; |
|
Rotates this vector to be orthogonal to vBase without changing its length, and returns it. The resulting vector will lie on the plane defined by the original value of this vector, and vBase. 00095 { float fLen = Length(); MakeOrthogonal( vBase ); SetLength( fLen ); return *this; }; |
|
Returns the square of the length of the vector. |
|
Returns the length of the vector. |
|
Returns the 2D length of the vector, ignoring the z element. |
|
Returns the distance between two points (this and another, represented as Vector objects). 00109 { return operator -(v).Length(); }; |
|
Returns the shortest distance between this point and a line defined by two other points (all points represented by vector objects). |
|
Converts this (2d) vector to represent itself as a linear combination of the supplied basis vectors. Returns the result. This function works in 2d, ignoring the Z component of all the vectors. The supplied basis vectors must not be parallel. This method figures out how to express this vector (x,y) as a linear combination of the two vector arguments. X is set to the multiplier on the first vector, and Y to the multiplier on the second vector. So the original vector could be reconstructed from the final one like this: original = x*v0 + y*v1 |
|
Converts this vector to represent itself as a linear combination of the supplied basis vectors. This method figures out how to express this vector (x,y,z) as a linear combination of the three vector arguments. X is set to the multiplier on the first vector, Y to the multiplier on the second vector, and Z to the multiplier on the third. The supplied basis vectors must not be parallel. So the original vector could be reconstructed from the final one like this: original = x*v0 + y*v1 + z*v2 |
|
This operation calculates the baricentric coordinates inside a quad where the quad corners are v0,v1,v2,v3. 2d points in this function are represented by 3d Vector objects, with the Z component ignored. This function works in 2d only. If v0, v1, v2 and v3 are the corners of a quad in a 2d space (such as UV space), and this object's (x,y) coordinates represent a point inside that quad, then this function will calculate the baricentric coordinates inside the quad (v0 and v3 are opposite corners). After this operation the following code can calculate the original value stored in the vector (this can help you understand what the function does): |
|
Returns the cosine of the angle between this vector and the one passed in. |
|
Returns the minimum of this and the argument vector. Minimums are calculated individually for z, y, and z. |
|
Returns the maximum of this and the argument vector. Maximums are calculated individually for z, y, and z. |
|
Returns the inverse of the vector. 00181 { return Vector( -x, -y, -z ); }; |
|
Returns the sum of a vector and a scalar. (The scalar is added to each component individually). 00186 { return Vector( x+f, y+f, z+f ); }; |
|
Returns the sum of two vectors. 00190 { return Vector( x+v.x, y+v.y, z+v.z ); }; |
|
Returns the difference between two vectors/points. 00194 { return Vector( x-v.x, y-v.y, z-v.z ); }; |
|
Returns the product of two vectors by components. 00198 { return Vector( x*v.x, y*v.y, z*v.z ); }; |
|
Returns the product of the vector and a scalar. 00202 { return Vector( x*f, y*f, z*f ); }; |
|
Returns the quotient of two vectors by components. 00206 { return Vector( x/v.x, y/v.y, z/v.z ); }; |
|
Returns the quotient of a vector and a scalar. 00210 { return operator *( 1.0f/f ); }; |
|
Returns the product of a vector and an integer. 00214 { return operator *( float(i) ); }; |
|
Returns the quotient of a vector and an integer. 00218 { return operator /( float(i) ); }; |
|
Returns the quotient of a vector and an unsigned integer. 00222 { return operator /( float(i) ); }; |
|
Returns the dot product of two vectors. |
|
Returns the cross product of two vectors. |
|
Returns true if the two vectors are identical, false otherwise. |
|
Returns true if the two vectors are different, false otherwise. 00245 { return !operator ==( v ); }; |
|
Returns true if the vector is not a zero vector, false otherwise. |
|
Returns true if the vector is a zero vector, false otherwise. 00251 { return !operator bool(); }; |
|
Sets this vector to equal another one and returns it. |
|
Sets this vector to equal another one and returns it. |
|
Subtracts the component values of another vector from this one's, and returns the result. |
|
Adds another vector to this one and returns the result. |
|
Multiplies the components of the vector with a scalar value and returns the result. |
|
Multiplies the vector with another vector by components and returns the result. |
|
Divides the vector by a scalar and returns the result. 00280 { return operator *=( 1.0f/f ); }; |
|
Returns a individual components of the vector.
00284 : 0 to 2. 00285 ) throw() { return m_aCoors[i]; }; |
|
Returns a component of the vector.
00289 : 0 to 2. 00290 ) throw() { return m_aCoors[i]; }; |
|
Returns a pointer to the data of the vector. Do not delete this pointer.
00293 { return &x; };
|
|
|
|
|
|
|
|